<?php 
require_once "../connexion.php";
//Appel au singleton Connexion
$maConnexion = ConnexionSingleton::getInstance();
$maConnexion->Connect();
require_once '../Model/userModel.php';
?>
<?php
if(isset($_GET["validation"]))
{
	if($_POST["login"] != "" && $_POST["password"] != "")
	{
		$login = $_POST["login"];
		$password = $_POST["password"];
		$user = new UserModel();
		$requete = $user->connexion_valide($login,$password);
		
		if($requete == 0)
		{
			echo 0;
		}
		else
		{
			echo 1;
			
			session_start();
			$_SESSION["identification"] = true;
			$_SESSION["id_user"] = $user->getId();
			$_SESSION["login"] = $user->getLogin();
		}
		
	}
	else
	{
		echo 0;
	}
}

if(isset($_GET["suppression"]))
{
	$id_user = $_POST["id_user"];
	$user = new UserModel();
	if($user->deleteUtilisateur($id_user))
	{
		echo "L'utilisateur n&deg; $id_user &agrave; &eacute;t&eacute; supprim&eacute;";
	}
	else
	{
		echo "Erreur lors de la suppression";
	}
}
?>